package br.com.agiledev.webscrum.entity;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.hibernate.annotations.ForeignKey;

import br.com.agiledev.webscrum.enumeration.ScrumRoleType;

/**
 * Entity implementation class for Entity: ScrumRole
 * 
 */
@Entity
@SequenceGenerator(name = "scrumRole", sequenceName = "se_scrumRole")
@Table(uniqueConstraints = {@UniqueConstraint(columnNames = {"team", "type", "user"})})
public class ScrumRole implements Serializable {

    private static final long serialVersionUID = 1L;
    
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "scrumRole")
    private Long oid;
    
    @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.REMOVE}, optional = false)
    @ForeignKey(name = "fk_scrumRole_team")
    private Team team;
    
    @Enumerated(EnumType.ORDINAL)
    @Column(nullable = false)
    private ScrumRoleType type;
    
    @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.REMOVE}, optional = false)
    @ForeignKey(name = "fk_scrumRole_user")
    private User user;
    
    public ScrumRole() {
    }
    
    public ScrumRole(Team team) {
	setTeam(team);
    }

    public Long getOid() {
	return this.oid;
    }

    public void setOid(Long oid) {
	this.oid = oid;
    }

    public ScrumRoleType getType() {
        return type;
    }

    public void setType(ScrumRoleType type) {
        this.type = type;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public Team getTeam() {
        return team;
    }

    public void setTeam(Team team) {
        this.team = team;
    }

}
